package foguing.test;

import static org.junit.Assert.assertEquals;

import org.apache.uima.collection.CollectionReaderDescription;
import org.apache.uima.fit.factory.CollectionReaderFactory;
import org.apache.uima.fit.pipeline.JCasIterable;
import org.apache.uima.fit.util.JCasUtil;
import org.apache.uima.jcas.JCas;
import org.junit.Test;

import com.unidue.foguing.task_B.Reader_TaskB;
import com.unidue.foguing.types.ActualSentiment;

public class ReaderTestTask_B {
	
	@Test
	public void test() throws Exception{
		CollectionReaderDescription reader = CollectionReaderFactory.createReaderDescription(
                Reader_TaskB.class,
                Reader_TaskB.INPUT_FILE, "src/test/resources/test/myTestTask_B.txt");
		
		int i = 0;
		for(JCas jCas : new JCasIterable(reader)){
			// we just know that the first line is positive , so test it !!!!!
			if(i == 0){
				assertEquals("Gas by my house hit $3.39!!!! I'm going to Chapel Hill on Sat. :)", jCas.getDocumentText());
				ActualSentiment actualSentiment = JCasUtil.selectSingle(jCas, ActualSentiment.class);
				assertEquals("positive" , actualSentiment.getActualSentiment());
			}
			
			System.out.println(jCas.getDocumentText());
			i++;
		}
		// there are 9 lines in the files.
		assertEquals(9,i);
	}
}
